package de.hsmannheim.poolraumapp.model;

import java.util.Iterator;
import java.util.List;

import org.joda.time.DateTime;

public class LessonBlocks implements Iterable<LessonBlock>{
	private DateTime lastModified;
	private List<LessonBlock> lessonBlocks;
	
	public LessonBlocks(DateTime lastModified, List<LessonBlock> lessonBlocks) {
		this.lastModified = lastModified;
		this.lessonBlocks = lessonBlocks;
	}
	
	public DateTime getLastModified() {
		return lastModified;
	}
	public List<LessonBlock> getLessonBlocks() {
		return lessonBlocks;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((lastModified == null) ? 0 : lastModified.hashCode());
		result = prime * result
				+ ((lessonBlocks == null) ? 0 : lessonBlocks.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		LessonBlocks other = (LessonBlocks) obj;
		if (lastModified == null) {
			if (other.lastModified != null)
				return false;
		} else if (!lastModified.equals(other.lastModified))
			return false;
		if (lessonBlocks == null) {
			if (other.lessonBlocks != null)
				return false;
		} else if (!lessonBlocks.equals(other.lessonBlocks))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "LessonBlocks [lastModified=" + lastModified + ", lessonBlocks="
				+ lessonBlocks + "]";
	}

	@Override
	public Iterator<LessonBlock> iterator() {
		return lessonBlocks.iterator();
	}
}
